#pragma strict

var vsyncText : TextMesh;
var curOption : int;
var setOption : String;
var buttonColorTo : Color32;
var buttonColorFrom : Color32;
var colorSpeed : float;

function Start(){

	buttonColorTo = Color32(246,255,0,0);
	buttonColorFrom = Color32(150,150,150,0);	
	colorSpeed = 20;
	setOption = "Disabled";
	curOption = 0;
	
	renderer.material.SetColor("_Color", buttonColorFrom);

}

function Update () {

	vsyncText.GetComponent(TextMesh).text = "VSync: "+setOption;

}

function OnMouseEnter() {

	iTween.ColorTo(gameObject, buttonColorTo, colorSpeed * Time.deltaTime);

}

function OnMouseExit() {

	iTween.ColorTo(gameObject, buttonColorFrom, colorSpeed * Time.deltaTime);

}



function OnMouseDown() {
	
	var CameraOptions = GameObject.Find("Main Camera").GetComponent(MainCamera);

	if(curOption == 2){
		curOption = 0;
	} else { 
		curOption += 1;
	}
	
	switch(curOption){
		case(0):
		QualitySettings.vSyncCount = 0;
		setOption = "Disabled";
		CameraOptions.speed = 450.0;
		break;
		
		case(1):
		QualitySettings.vSyncCount = 1;
		setOption = "Enabled";
		CameraOptions.speed = 150.0;
		break;
		
		case(2):
		QualitySettings.vSyncCount = 2;
		setOption = "Enabled (Two-Pass)";
		CameraOptions.speed = 150.0;
		break;
	}

}

